/*
struct ListNode {
	int val;
	struct ListNode *next;
	ListNode(int x) :
			val(x), next(NULL) {
	}
};*/
class Solution {
public:
    // 快慢指针法
    ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) {
        if(pListHead == nullptr || k == 0)
            return nullptr;
        ListNode* fast = pListHead, *slow = pListHead;
        // 快指针先走n步
        while(k--){
            if(fast == nullptr)  // k超出范围，fast已经走到表尾
                return nullptr;
            fast = fast->next;
        }
        // 当fast走到null时，slow正好指向倒数第k个节点   
        while(fast != nullptr){
            fast = fast->next;
            slow = slow->next;
        }
        return slow;
    }
};